﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Wwtfly.Utility
{

    /// <summary>
    /// 登陆的用户 相关
    /// </summary>
    public class LoginUserUtil
    {
        /// <summary>
        /// 存储登陆用户Session
        /// </summary>
        public static readonly string LOGIN_USER = "login_user";
        /// <summary>
        /// 后台登陆地址
        /// </summary>
        public static readonly string BackLoginUrl = "~/BackHome/Login.html";
        /// <summary>
        /// 前台地址
        /// </summary>
        public static readonly string ForeLoginUrl = "~/WebForm/login.html";

        /// <summary>
        /// 获取 当前登陆用户
        /// </summary>
        /// <returns>当前登录用户信息 如果为null表示没有登录 或者登录超时</returns>
        public static T GetCurrentUserInfo<T>()
        {
            T userInfo = default(T);
            if (HttpContext.Current.Session[LOGIN_USER] != null)
            {
                userInfo = (T)HttpContext.Current.Session[LOGIN_USER];
            }
            return userInfo;
        }
    }
}
